import fs from 'node:fs'

export class DataBase {
  static read() {
    const fileData = fs.readFileSync('./data.json')
    try {
      return JSON.parse(fileData)
    } catch {
      console.log('数据库读取异常')
    }
  }

  static write(list) {
    try {
      const data = JSON.stringify(list)
      fs.writeFileSync('./data.json', data)
    } catch {
      console.log('数据库写入异常')
    }
  }
}
